//
//  CCTCPSocketClient.h
//  IntellDev_new
//
//  Created by os on 2021/3/5.
//

#import <Foundation/Foundation.h>

#include "UnixInterfaceDefine.h"
#include "CCTCPDataDefine.h"
#include "H264Decoder.h"
#include "H264HWDecoder.h"
#include "CCVideoDecoder.h"


@protocol TCPSocketClientDelegate <NSObject>

@optional

- (void)cameraUpdateDecodedH264FrameData:(H264YUV_Frame *)yuvFrame;
- (void)cameraUpdateDecodedH264SampleBuffer:(CMSampleBufferRef)sampleBuffer;
- (void)cameraUpdateDecodedH264PixelBuffer:(CVPixelBufferRef)imageBuffer;

@end

@interface CCTCPSocketClient : NSObject
{
    
    // 保留网络登陆用户信息
    char                m_IPAddress[64];            // camIP
    int                 m_port;                     // 端口
    char                m_userName[13];             // 用户名
    char                m_password[13];             // 密码
    
    int                 m_cSockfd;                  // 命令套接字
    int                 m_dSockfd;                  // 数据通道套接字
    
    int                 m_videoID;                  // 视频ID
    
    struct sockaddr_in  m_cSockaddr_in;
    struct sockaddr_in  m_dSockaddr_in;
    
    bool                m_recvDataToggle;
    bool                m_recvCommandToggle;
    
    NSTimer             *keepAliveTimer;
    
    pthread_mutex_t     mutex_cRecv;
    pthread_mutex_t     mutex_cSend;
    pthread_mutex_t     mutex_dRecv;
    pthread_mutex_t     mutex_dSend;
    
}

@property (nonatomic, weak) id<TCPSocketClientDelegate> tcpSocketDelegate;

- (bool)startTCPSocketConnection:(CC_NetConnectInfo *)connectionInfo;
- (void)stopTCPSocketClient;
- (bool)startListenCommand;
- (bool)stopListenCommand;

@end

